import { createRouter, createWebHistory } from 'vue-router'
import type { RouteRecordRaw } from 'vue-router'

const routes: RouteRecordRaw[] = [
  {
    path: '/',
    redirect: '/auth/login',
  },
  {
      path: '/cashier/beefgate',
      name: 'Beefgate',
      component: () => import('@/views/cashier/beefgate/index.vue'),
      props: true
  },
  {
    path: '/auth',
    children: [
      {
        path: 'login',
        name: 'Login',
        component: () => import('@/views/auth/login/index.vue'),
      },
      {
        path: 'register',
        name: 'Register',
        component: () => import('@/views/auth/register/index.vue'),
      },
    ],
  },
  {
    path: '/',
    component: () => import('@/layouts/pc/MainLayout.vue'),
    children: [
      {
        path: 'dashboard',
        name: 'Dashboard',
        component: () => import('@/views/dashboard/index.vue'),
      },
      {
        path: 'qrcode',
        name: 'Qrcode',
        component: () => import('@/views/qrcode/index.vue'),
      },
      {
        path: 'channel',
        name: 'Channel',
        component: () => import('@/views/channel/index.vue'),
      },
      {
        path: 'app',
        name: 'App',
        component: () => import('@/views/app/index.vue'),
      },
      {
        path: 'static-pay-code-test',
        name: 'staticPayCodeTest',
        component: () => import('@/views/StaticPayCodeTest.vue'),
        meta: { title: '静态聚合码测试' }
      },
      {
        path: 'dynamic-pay-code-test',
        name: 'dynamicPayCodeTest',
        component: () => import('@/views/dynamic.vue'),
        meta: { title: '动态聚合码测试' }
      },
      {
        path: 'pay-test',
        name: 'payTest',
        component: () => import('@/views/pay-test/index.vue'),
        meta: { title: '支付测试' }
      },
      {
        path: 'test-api',
        name: 'apiTest',
        component: () => import('@/views/ApiTest.vue'),
        meta: { title: 'API测试' }
      },
      {
        path: 'grade-protection',
        name: 'GradeProtection',
        component: () => import('@/views/grade-protection/index.vue'),
        meta: { title: '等级保护' }
      },
      {
        path: 'system-settings',
        name: 'SystemSettings',
        children: [
          {
            path: 'overview',
            name: 'ConfigOverview',
            component: () => import('@/views/system-settings/overview/index.vue'),
            meta: { title: '配置概览' }
          },
          {
            path: 'basic',
            name: 'BasicSettings',
            component: () => import('@/views/system-settings/basic/index.vue'),
            meta: { title: '基本设置' }
          },
          {
            path: 'security',
            name: 'SecuritySettings',
            component: () => import('@/views/system-settings/security/index.vue'),
            meta: { title: '安全设置' }
          },
          {
            path: 'third-party',
            name: 'ThirdPartyConfig',
            component: () => import('@/views/system-settings/third-party/index.vue'),
            meta: { title: '第三方配置' },
            children: [
              {
                path: '',
                name: 'StorageSettings',
                component: () => import('@/views/system-settings/third-party/storage.vue'),
                meta: { title: '存储配置' }
              },
              {
                path: 'storage',
                name: 'StorageSettingsAlias',
                component: () => import('@/views/system-settings/third-party/storage.vue'),
                meta: { title: '存储配置' }
              },
              {
                path: 'sms',
                name: 'SmsSettings',
                component: () => import('@/views/system-settings/third-party/sms.vue'),
                meta: { title: '短信配置' }
              },
              {
                path: 'map',
                name: 'MapSettings',
                component: () => import('@/views/system-settings/third-party/map.vue'),
                meta: { title: '地图配置' }
              },
              {
                path: 'ocr',
                name: 'OcrSettings',
                component: () => import('@/views/system-settings/third-party/ocr.vue'),
                meta: { title: 'OCR配置' }
              }
            ]
          }
        ]
      },
      {
        path: 'settings',
        name: 'Settings',
        component: () => import('@/views/settings/index.vue'),
        meta: { title: '设置' },
        children: [
          {
            path: '',
            name: 'SettingsBasic',
            component: () => import('@/views/settings/basic.vue'),
            meta: { title: '基本设置' }
          },
          {
            path: 'security',
            name: 'SettingsSecurity',
            component: () => import('@/views/settings/security.vue'),
            meta: { title: '安全设置' }
          },
          {
            path: 'storage',
            name: 'SettingsStorage',
            component: () => import('@/views/settings/storage.vue'),
            meta: { title: '存储配置' }
          },
          {
            path: 'sms',
            name: 'SettingsSms',
            component: () => import('@/views/settings/sms.vue'),
            meta: { title: '短信配置' }
          },
          {
            path: 'map',
            name: 'SettingsMap',
            component: () => import('@/views/settings/map.vue'),
            meta: { title: '地图配置' }
          },
          {
            path: 'ocr',
            name: 'SettingsOcr',
            component: () => import('@/views/settings/ocr.vue'),
            meta: { title: 'OCR配置' }
          }
        ]
      },
      {
        path: 'profile',
        name: 'Profile',
        component: () => import('@/views/profile/index.vue'),
      },
      {
        path: 'merchant-management',
        name: 'MerchantManagement',
        children: [
          {
            path: 'merchant-list',
            name: 'MerchantList',
            component: () => import('@/views/merchant-management/merchant-list/index.vue'),
            meta: { title: '商户列表' }
          },
          {
            path: 'store-list',
            name: 'StoreList',
            component: () => import('@/views/merchant-management/store-list/index.vue'),
            meta: { title: '门店列表' }
          }
        ]
      },
      {
        path: 'merchant-onboarding',
        name: 'MerchantOnboarding',
        children: [
          {
            path: 'pre-onboarding',
            name: 'PreOnboarding',
            component: () => import('@/views/merchant-onboarding/pre-onboarding/index.vue'),
            meta: { title: '预进件' }
          },
          {
            path: 'channel-onboarding',
            name: 'ChannelOnboarding',
            component: () => import('@/views/merchant-onboarding/channel-onboarding/index.vue'),
            meta: { title: '渠道进件' }
          }
        ]
      },
      {
        path: 'order-management',
        name: 'OrderManagement',
        children: [
          {
            path: 'payment',
            name: 'PaymentOrders',
            component: () => import('@/views/order-management/payment/index.vue'),
            meta: { title: '支付订单' }
          },
          {
            path: 'refund',
            name: 'RefundOrders',
            component: () => import('@/views/order-management/refund/index.vue'),
            meta: { title: '退款订单' }
          }
        ]
      },
      {
        path: 'transaction-notifications',
        name: 'TransactionNotifications',
        children: [
          {
            path: 'channel',
            name: 'ChannelNotifications',
            component: () => import('@/views/transaction-notifications/channel-notifications/index.vue'),
            meta: { title: '渠道通知' }
          },
          {
            path: 'merchant',
            name: 'MerchantCallbacks',
            component: () => import('@/views/transaction-notifications/merchant-callbacks/index.vue'),
            meta: { title: '商户回调' }
          }
        ]
      },
      {
        path: 'reconciliation',
        name: 'Reconciliation',
        children: [
          {
            path: 'channel',
            name: 'ChannelReconciliation',
            component: () => import('@/views/reconciliation/channel/index.vue'),
            meta: { title: '渠道对账' }
          },
          {
            path: 'merchant',
            name: 'MerchantReconciliation',
            component: () => import('@/views/reconciliation/merchant/index.vue'),
            meta: { title: '商户对账' }
          },
          {
            path: 'error-handling',
            name: 'ErrorHandling',
            component: () => import('@/views/reconciliation/error-handling/index.vue'),
            meta: { title: '差错处理' }
          },
          {
            path: 'files',
            name: 'ReconciliationFiles',
            component: () => import('@/views/reconciliation/files/index.vue'),
            meta: { title: '对账文件' }
          },
          {
            path: 'settlement',
            name: 'Settlement',
            component: () => import('@/views/reconciliation/settlement/index.vue'),
            meta: { title: '结算管理' }
          }
        ]
      },
      {
        path: 'data-statistics',
        name: 'DataStatistics',
        children: [
          {
            path: 'transaction',
            name: 'TransactionStatistics',
            component: () => import('@/views/data-statistics/transaction/index.vue'),
            meta: { title: '交易统计' }
          },
          {
            path: 'merchant',
            name: 'MerchantStatistics',
            component: () => import('@/views/data-statistics/merchant/index.vue'),
            meta: { title: '商户统计' }
          },
          {
            path: 'channel',
            name: 'ChannelStatistics',
            component: () => import('@/views/data-statistics/channel/index.vue'),
            meta: { title: '渠道统计' }
          },
          {
            path: 'revenue',
            name: 'RevenueStatistics',
            component: () => import('@/views/data-statistics/revenue/index.vue'),
            meta: { title: '收入统计' }
          },
          {
            path: 'trend',
            name: 'TrendAnalysis',
            component: () => import('@/views/data-statistics/trend/index.vue'),
            meta: { title: '趋势分析' }
          },
          {
            path: 'realtime',
            name: 'RealtimeMonitor',
            component: () => import('@/views/data-statistics/realtime/index.vue'),
            meta: { title: '实时监控' }
          }
        ]
      },

      {
        path: 'article',
        name: 'Article',
        component: () => import('@/views/article/index.vue'),
        meta: { title: '文章管理' }
      },
      {
        path: 'article/detail/:id',
        name: 'ArticleDetail',
        component: () => import('@/views/article/detail.vue'),
        meta: { title: '文章详情' }
      },
      {
        path: 'frontend-components',
        name: 'FrontendComponents',
        component: () => import('@/views/frontend-components/index.vue'),
        meta: { title: '前端组件' },
        children: [
          {
            path: '',
            name: 'ComponentsOverview',
            component: () => import('@/views/frontend-components/overview.vue'),
            meta: { title: '前端组件概览' }
          },
          {
            path: 'file-upload-demo',
            name: 'FileUploadDemo',
            component: () => import('@/views/frontend-components/file-upload-demo/index.vue'),
            meta: { title: '文件上传组件' },
            children: [
              {
                path: '',
                name: 'FileUploadExample',
                component: () => import('@/views/frontend-components/file-upload-demo/example.vue'),
                meta: { title: '基础示例' }
              },
              {
                path: 'simple',
                name: 'SimpleFileUploadExample',
                component: () => import('@/views/frontend-components/file-upload-demo/simple.vue'),
                meta: { title: '简洁组件示例' }
              }
            ]
          },
          {
            path: 'data-display-demo',
            name: 'DataDisplayDemo',
            component: () => import('@/views/frontend-components/data-display-demo/index.vue'),
            meta: { title: '数据展示组件' },
            children: [
              {
                path: '',
                name: 'StatisticsCardsExample',
                component: () => import('@/views/frontend-components/data-display-demo/statistics.vue'),
                meta: { title: '统计卡片' }
              },
              {
                path: 'table',
                name: 'DataTableExample',
                component: () => import('@/views/frontend-components/data-display-demo/table.vue'),
                meta: { title: '数据表格' }
              },
              {
                path: 'charts',
                name: 'DataChartsExample',
                component: () => import('@/views/frontend-components/data-display-demo/charts.vue'),
                meta: { title: '图表展示' }
              }
            ]
          },
          {
            path: 'form-demo',
            name: 'FormDemo',
            component: () => import('@/views/frontend-components/form-demo/index.vue'),
            meta: { title: '表单组件' },
            children: [
              {
                path: '',
                name: 'BasicFormExample',
                component: () => import('@/views/frontend-components/form-demo/basic.vue'),
                meta: { title: '基础表单' }
              },
              {
                path: 'advanced',
                name: 'AdvancedFormExample',
                component: () => import('@/views/frontend-components/form-demo/advanced.vue'),
                meta: { title: '高级表单' }
              },
              {
                path: 'validation',
                name: 'FormValidationExample',
                component: () => import('@/views/frontend-components/form-demo/validation.vue'),
                meta: { title: '表单验证' }
              }
            ]
          },
          {
            path: 'interaction-demo',
            name: 'InteractionDemo',
            component: () => import('@/views/frontend-components/interaction-demo/index.vue'),
            meta: { title: '交互组件' },
            children: [
              {
                path: '',
                name: 'ModalExample',
                component: () => import('@/views/frontend-components/interaction-demo/modal.vue'),
                meta: { title: '弹窗组件' }
              },
              {
                path: 'drawer',
                name: 'DrawerExample',
                component: () => import('@/views/frontend-components/interaction-demo/drawer.vue'),
                meta: { title: '抽屉组件' }
              },
              {
                path: 'notification',
                name: 'NotificationExample',
                component: () => import('@/views/frontend-components/interaction-demo/notification.vue'),
                meta: { title: '通知组件' }
              }
            ]
          }
        ]
      },
      // 学生管理路由
      {
        path: 'student-management',
        name: 'StudentManagement',
        component: () => import('@/miaoma/manual/student/List.vue'),
        meta: {
          title: '学生管理',
          icon: 'user-outlined',
          keepAlive: false,
        },
      },
      // 服务商渠道配置路由
      {
        path: 'provider-channel-config',
        name: 'ProviderChannelConfigList',
        component: () => import('@/miaoma/manual/provider-channel-config/List.vue'),
        meta: {
          title: '服务商渠道配置',
          icon: 'setting-outlined',
          keepAlive: true,
        },
      },
      {
        path: 'provider-channel-config/add',
        name: 'ProviderChannelConfigAdd',
        component: () => import('@/miaoma/manual/provider-channel-config/AddOrEdit.vue'),
        meta: {
          title: '新增服务商渠道配置',
        },
      },
      {
        path: 'provider-channel-config/edit/:id',
        name: 'ProviderChannelConfigEdit',
        component: () => import('@/miaoma/manual/provider-channel-config/AddOrEdit.vue'),
        meta: {
          title: '编辑服务商渠道配置',
        },
      },
      {
        path: 'provider-channel-config/detail/:id',
        name: 'ProviderChannelConfigDetail',
        component: () => import('@/miaoma/manual/provider-channel-config/Detail.vue'),
        meta: {
          title: '服务商渠道配置详情',
        },
      },
    ],
  },
  {
    path: '/pay',
    component: () => import('@/layouts/pay/PayLayout.vue'),
    children: [
      {
        path: '',
        name: 'pay',
        component: () => import('@/views/pay/index.vue'),
        props: true
      },
      {
        path: 'alipay',
        name: 'alipayPay',
        component: () => import('@/views/pay/alipay/index.vue'),
        props: true
      },
      {
        path: 'alipay/success',
        name: 'alipayPaySuccess',
        component: () => import('@/views/pay/alipay/success.vue')
      },
      {
        path: 'alipay/failed',
        name: 'alipayPayFailed',
        component: () => import('@/views/pay/alipay/fail.vue')
      },
      {
        path: 'alipay-isv',
        name: 'alipayIsvPay',
        component: () => import('@/views/pay/alipay-isv/index.vue'),
        props: true
      },
      {
        path: 'alipay-isv/success',
        name: 'alipayIsvPaySuccess',
        component: () => import('@/views/pay/alipay-isv/success.vue')
      },
      {
        path: 'alipay-isv/failed',
        name: 'alipayIsvPayFailed',
        component: () => import('@/views/pay/alipay-isv/fail.vue')
      },
      {
        path: 'wechat',
        name: 'wechatPay',
        component: () => import('@/views/pay/wechat/index.vue'),
        props: true
      },
      {
        path: 'wechat/success',
        name: 'wechatPaySuccess',
        component: () => import('@/views/pay/wechat/success.vue')
      },
      {
        path: 'wechat/failed',
        name: 'wechatPayFailed',
        component: () => import('@/views/pay/wechat/fail.vue')
      },
      {
        path: 'wechat/closed',
        name: 'wechatPayClosed',
        component: () => import('@/views/pay/wechat/close.vue')
      },
      {
        path: 'wechat-isv',
        name: 'wechatIsvPay',
        component: () => import('@/views/pay/wechat-isv/index.vue'),
        props: true
      },
      {
        path: 'wechat-isv/success',
        name: 'wechatIsvPaySuccess',
        component: () => import('@/views/pay/wechat-isv/success.vue')
      },
      {
        path: 'wechat-isv/failed',
        name: 'wechatIsvPayFailed',
        component: () => import('@/views/pay/wechat-isv/fail.vue')
      },
      {
        path: 'wechat-isv/closed',
        name: 'wechatIsvPayClosed',
        component: () => import('@/views/pay/wechat-isv/close.vue')
      },
      {
        path: 'leshua-alipay',
        component: () => import('@/views/pay/leshua-alipay/index.vue')
      },
      {
        path: 'leshua-alipay/success',
        component: () => import('@/views/pay/leshua-alipay/success.vue')
      },
      {
        path: 'leshua-alipay/fail',
        component: () => import('@/views/pay/leshua-alipay/fail.vue')
      },
      {
        path: 'leshua-wxpay',
        component: () => import('@/views/pay/leshua-wxpay/index.vue')
      },
      {
        path: 'leshua-wxpay/success',
        component: () => import('@/views/pay/leshua-wxpay/success.vue')
      },
      {
        path: 'leshua-wxpay/fail',
        component: () => import('@/views/pay/leshua-wxpay/fail.vue')
      }
    ]
  },
]

const router = createRouter({
  history: createWebHistory(),
  routes,
})

export default router